#include <iostream>
#include <cstdio>
using namespace std;
int n,a[5010],k[5010];
int main ()
{
	freopen("seq.in","r",stdin);
	freopen("seq.out","w",stdout);
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		k[i]=1;
	}
	int l,c;
	for (int i=n-1;i>=1;i--)
	{
		l=0,c=0;
		for (int j=i+1;j<=n;j++)
			if (a[j]>=a[i]&&l<k[j])
			{
				l=k[j];
				c=j;
			}
		if (l>0)
			k[i]=l+1;
	}
	c=1;
	for (int j=1;j<=n;j++)
		if (k[j]>k[c])
			c=j;
	cout<<k[c];
	return 0;
}
